package com.zs.mp.service.impl;

import java.util.List;

import org.apache.ibatis.builder.MapperBuilderAssistant;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.core.MybatisConfiguration;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.TableInfoHelper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zs.mp.dao.IUserMapper;
import com.zs.mp.model.User;
import com.zs.mp.model.UserDTO;
import com.zs.mp.model.vo.UserVO;
import com.zs.mp.service.IUserService;

import jakarta.annotation.Resource;

@Service
public class UserServiceImpl extends ServiceImpl<IUserMapper, User> implements IUserService{
	
	@Resource
	private IUserMapper userMapper;
	
	public List<UserVO> listAllUser() {
		userMapper.selectList(null);
		return null;
	}

	@Override
	public User getUserById(Integer userId) {
		LambdaQueryWrapper<User> lqw = new LambdaQueryWrapper<User>();
		lqw.eq(User::getId, userId);
		return userMapper.getUserById(lqw);
	}

	@Override
	public List<User> listUserByCondition(UserDTO userDTO) {
//		QueryWrapper<UserDTO> qw = new QueryWrapper<UserDTO>();
//		qw.ge("id", 1);
//		return userMapper.listUserByCondition(qw);
		TableInfoHelper.initTableInfo(new MapperBuilderAssistant(new MybatisConfiguration(), ""), UserDTO.class);
		LambdaQueryWrapper<UserDTO> lqw = new LambdaQueryWrapper<UserDTO>(UserDTO.class);
		lqw.ge(UserDTO::getId, 1);
		
		return userMapper.listUserByCondition(lqw);
	}

}
